using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Models.ServerModels;
using Models;
using Models.APIModels;

namespace DdnsServer.DnspodAPI
{
    public class UserApi : APIBase
    {
        public UserApi(ApiConfigModel cfg):base(cfg)
        {
            
        }
        #region 获取账户信息
        /// <summary>
        /// 获取用户信息
        /// </summary>
        /// <returns></returns>
        public UserModel GetUserInfo()
        {
           return  PostData<UserModel>("User.Detail", null);
        }
        #endregion
        #region 修改资料
        /// <summary>
        /// 修改资料
        /// </summary>
        /// <param name="realName">姓名</param>
        /// <param name="nickName">昵称</param>
        /// <param name="ntelephone">电话号码</param>
        /// <returns></returns>
        public RetMessageModel EditUserProfile(string realName,string nickName,string ntelephone)
        {
            Dictionary<string,object> param = new Dictionary<string, object>
            {
                ["real_name"] = realName,
                ["nick"] = nickName,
                ["telephone"] = ntelephone
            };
            return PostData<RetMessageModel>("User.Modify", param);
        }
        #endregion
        #region 修改密码
        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="oldPass">旧密码</param>
        /// <param name="newPass">新密码</param>
        /// <returns></returns>
        public RetMessageModel EditPassword(string oldPass,string newPass)
        {
            Dictionary<string,object> param = new Dictionary<string, object>
            {
                ["old_password"] = oldPass,
                ["new_password"] = newPass
            };
            return PostData<RetMessageModel>("UserPasswd.Modify", param);
        }
        #endregion
        #region 修改邮箱
        /// <summary>
        /// 修改邮箱
        /// </summary>
        /// <param name="oldMail">旧邮箱</param>
        /// <param name="newMail">新邮箱</param>
        /// <param name="pwd">密码</param>
        /// <returns></returns>
        public RetMessageModel EditMail(string oldMail,string newMail,string pwd)
        {
            Dictionary<string,object> param = new Dictionary<string, object>
            {
                ["old_email"] = oldMail,
                ["new_email"] = newMail,
                ["password"] = pwd
            };
            return PostData<RetMessageModel>("Useremail.Modify", param);
        }
        #endregion
        #region 获取手机验证码
        public TelVerifyModel GetTelVerifyCode(string mobNumer)
        {
            Dictionary<string,object> param = new Dictionary<string, object> { ["telephone"] = mobNumer };
            return PostData<TelVerifyModel>("Telephoneverify.Code", param);
        }
        #endregion
        #region 获取用户日志
        public UserLogModel GetUserLogs()
        {
            return PostData<UserLogModel>("User.Log", null);
        }
        #endregion
    }
}
